package freebase;

import ioUtility.*;
import java.io.*;

public class ToyData {
	static String dir = "O:/unix/projects/pardosa/data06/clzhang";
	static String freebasedir = dir + "/freebase";
	static String wexdir = dir + "/wex";
	static String toyfreebase = dir + "/freebase_toy2";

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		// BufferedReader br =
		// ioUtility.FileAccess.OpenLineRead(freebasedir+"/quadruples.tsv",
		// "utf-8");
		// String content = readsomelines(br,100);
		// ioUtility.FileAccess.writeFile(toyfreebase+"/quadruples.tsv",content,"utf-8");
		// br.close();
		toyonefile("quadruples.tsv");
		toyonefile("simple-topic.tsv");
		toyonefile2("articles.tsv");
		toyonefile2("category_members.tsv");
		toyonefile2("freebase_names.tsv");
		toyonefile2("freebase_types.tsv");
		toyonefile2("freebase_wpid.tsv");
		toyonefile2("redirects.tsv");
		toyonefile2("sections.tsv");
		toyonefile2("template_calls.tsv");
		toyonefile2("template_values.tsv");

		// TODO Auto-generated method stub
	}
	
	
	public static void toyonefile(String name) throws Exception {
		BufferedReader br = ioUtility.FileAccess.OpenLineRead(freebasedir + "/"
				+ name, "utf-8");
		String content = readsomelines(br, 100);
		ioUtility.FileAccess.writeFile(toyfreebase + "/" + name, content,
				"utf-8");
		br.close();
	}

	public static void toyonefile2(String name) throws Exception {
		BufferedReader br = ioUtility.FileAccess.OpenLineRead(wexdir + "/"
				+ name, "utf-8");
		String content = readsomelines(br, 100);
		ioUtility.FileAccess.writeFile(toyfreebase + "/" + name, content,
				"utf-8");
		br.close();
	}

	public static String readsomelines(BufferedReader br, int n)
			throws Exception {
		String res = "";
		String line = "";
		int i = 0;
		while ((line = br.readLine()) != null && i < n) {
			// String []abc = line.split("\t");
			// System.out.println(abc.length);
			res += line + "\n";
			i++;
		}
		return res;
	}

}
